package com.simulate2.demo.controller;

import com.simulate2.demo.dao.CommisionRepository;
import com.simulate2.demo.service.OrderService;
import com.simulate2.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.Date;

@Controller
public class OrderController {
    @Resource
    private OrderService orderService;
    @Autowired
    private UserService userService;

    @RequestMapping("/produceOrder")
    public String produceOrder(String p_date, String p_num) {
        orderService.produceOrder(Integer.parseInt(p_num), Integer.parseInt(p_date));
        orderService.caluOrdersByDay(Integer.parseInt(p_date));
        return "index";
    }

    @RequestMapping("/test")
    public String test(){
        Date date5 = new Date();                    //获得当前时间
        System.out.println("核算1000 0000订单的总佣金，并计算1000 0000用户的每人分拥，所需时间---->开始时间："+date5);
        orderService.caluOrdersByDay(20200122);
        Date date6 = new Date();                    //获得当前时间
        System.out.println("结束时间："+date6+"  共耗时："+(date6.getTime()-date5.getTime()));

        return "index";
    }


}
